package com.usian.admin.controller;

import com.usian.admin.service.AdChannelService;
import com.usian.api.admin.AdchannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
@Api(tags = "channel",value ="频道管理",description = "频道管理Api")
public class AdChannelController implements AdchannelControllerApi {

    @Autowired
    private AdChannelService adChannelService;
    @PostMapping("/list")
    @Override
    @ApiOperation(value = "查询频道信息",notes = "根据名称分页查询频道列表")
    @ApiImplicitParam(name = "channelDto",type = "channelDto",value = "查询姓名")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto channelDto) {
        return adChannelService.findByNameAndPage(channelDto);
    }

    @PostMapping("/save")
    @Override
    @ApiOperation(value = "新增频道信息",notes = "新增频道信息")
    @ApiImplicitParam(name = "adChannel",type = "adChannel",value = "添加对象")
    public ResponseResult save(@RequestBody AdChannel adChannel) {
        return adChannelService.insert(adChannel);
    }
    @PutMapping("/update")
    @Override
    @ApiOperation(value = "修改频道",notes = "修改频道")
    @ApiImplicitParam(name = "adChannel",type = "adChannel",value = "修改对象")
    public ResponseResult update(@RequestBody  AdChannel adChannel) {
        return adChannelService.update(adChannel);
    }

    @DeleteMapping("/deleteById/{id}")
    @Override
    @ApiOperation(value = "删除频道",notes = "删除频道")
    @ApiImplicitParam(name = "Integer",type = "id",value = "修改对象")
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adChannelService.deleteById(id);
    }
}
